package com.zpark.it.controller;

import com.zpark.it.param.ProductCollectParam;
import com.zpark.it.service.ProductService;
import com.zpark.it.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: ProductCollectController
 * @Author Charles
 * @Package com.zpark.it.controller
 * @Date 2023/7/25 20:27
 */
@RestController
@RequestMapping("product")
public class ProductCollectController {

    @Autowired
    private ProductService productService;

    @PostMapping("collect/list")
    public R productIds(@RequestBody @Validated ProductCollectParam productCollectParam, BindingResult result){
        if (result.hasErrors()){
            return R.fail("没有收藏数据");
        }
        return productService.ids(productCollectParam.getProductIds());
    }

}
